ResourceRequest 资源请求

从资源包异步加载请求。

变量 说明
asset 正被加载的资源对象。(只读)
    using UnityEngine;
    using System.Collections;

    public class ExampleClass : MonoBehaviour {
        void Start() {
            StartCoroutine(LoadTexture());
        }
        IEnumerator LoadTexture() {
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            ResourceRequest request = Resources.LoadAsync<Texture2D>("glass");
            yield return request;
            go.renderer.material.mainTexture = request.asset;
        }
    }

🔚